<!DOCTYPE html>
<html lang="zh-CN">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>Document</title>
</head>

<body>
  <script>
    /* 
      1.在es6中,类没有变量名的提升,必须先定义后创建
      2.类里面的公共的属性和方法,一定要使用this关键字来调用
     */
    class Father {
      constructor(uname, age) {
        // constructor里面的this 指向的是创建的实列对象
        this.uname = uname;
        this.age = age;
        this.sing();
      }
      sing() {
        console.log(`我要唱歌了...`);
      }
    };
    let ldh = new Father("好人",18);
  </script>

</body>

</html>